import { _decorator, Component, Node } from 'cc';
import DataMgr from '../../../../utils/DataMgr';
import { EVENT_NAMES } from '../../../../utils/Enums';
const { ccclass, property } = _decorator;

@ccclass('OperatePanel')
export class OperatePanel extends Component {
    @property({ type: Node, displayName: "锁住的位置" })
    lockMove: Node;

    start() {
        this.initListener()
        this.updateColors()
        
        // const locs = []
        // for (var i = 0; i < 4; i++) {
        //     const node = this.node.getChildByName("块面板").getChildByName("底槽" + (i + 1))
        //     locs.push(node.position)

        //     console.log (node.worldPosition)
        // }
    }

    protected onDestroy(): void {
        gg.systemEvent.off(EVENT_NAMES.PROPERTY_REFRESH, this.onRefreshEvent, this)
        gg.systemEvent.off(EVENT_NAMES.UPDATE_OPERATE_COLORS, this.updateColors, this)
    }


    // -------------------- 初始化 -------------------- //
    private initListener() {
        gg.systemEvent.on(EVENT_NAMES.PROPERTY_REFRESH, this.onRefreshEvent, this)
        gg.systemEvent.on(EVENT_NAMES.UPDATE_OPERATE_COLORS, this.updateColors, this)
    }

    // -------------------- 事件 -------------------- //
    private onRefreshEvent() {
        console.log ("刷新事件 ----------------> ")
    }

    private brickClicked() {
        console.log ("点击 ====》")
    }

    private updateColors() {
    }

    // 解锁
    private unLockClicked(event) {
        console.log (event.target.name)
        this.lockMove.active = true
    }
}


